/**
 * ThreadPane.java
 * @author: liuex
 * 2007-12-31 ����03:52:59
 *
 * note: 
 */
package lex.mtd.ui.details;

import javax.swing.JTable;
import javax.swing.table.TableColumnModel;

import lex.mtd.core.DownloadManager;
import lex.mtd.ui.utils.PercentRenderer;

public class ThreadTable extends JTable {
	private ThreadTableModel tableModel = null;

	// private DownloadManager dm = null;

	public ThreadTable() {
		this.initialize();
	}

	public void setDownloadManager(DownloadManager dm) {
		// this.dm = dm;
		this.getTableModel().setThreadSet(dm.getThreadSet());
	}

	ThreadTableModel getTableModel() {
		if (null == tableModel)
			tableModel = new ThreadTableModel();
		return tableModel;
	}

	private void initialize() {
		this.setModel(this.getTableModel());
		this.setName(getClass().getName() + ".table");
		this.setFillsViewportHeight(true);
		this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		TableColumnModel model = this.getColumnModel();
		int column = model.getColumnCount();
		for (int i = 0; i < column; i++)
			model.getColumn(i).setPreferredWidth(120);
		model.getColumn(4).setCellRenderer(new PercentRenderer());
	}
}
